Skip to content

[pallet-revive] EIP-7702 (continued)#12229

Open
0xRVE wants to merge 188 commits into
masterfrom
rve/eip-7702
Open

[pallet-revive] EIP-7702 (continued)#12229
0xRVE wants to merge 188 commits into
masterfrom
rve/eip-7702

Conversation

@0xRVE
Copy link
Copy Markdown
Contributor

@0xRVE 0xRVE commented May 29, 2026

Continuation of #10851.

Implements EIP-7702 ("Set EOA Account Code") for pallet-revive: an EOA can sign an authorization designating a contract whose code runs on its behalf, while using the EOA's own storage and balance. See #9569 for background.

Changes

Pallet integration. eth_call now takes an authorization_list (Vec<AuthorizationListEntry>) and processes it before the call. List size is bounded by gas: each entry must be covered by worst_case_delegation_deposit(), and an empty list on a type-4 tx is rejected in into_call.

Updating the eth_call signature is safe — it's not dispatched directly by users, but is the inner call of eth_transact (signed by an Ethereum wallet, submitted via eth-rpc).

Authorization processing. process_authorizations validates each entry (chain ID, signature, nonce, account type), creates the authority account if needed, and sets/clears the delegation. Invalid entries are silently skipped per spec; the function is otherwise fallible (e.g. insufficient funds for an account's ED). Delegation changes are applied outside the call's transactional context, so they persist even if the call reverts.

Revive-specific cost. Per-authorization gas is higher than EVM: an entry may create a new account (needs ED), and delegating to a contract requires a code-lockup deposit plus a refcount bump on the code hash.

Storage. New AccountType::DelegatedEOA { delegate_target: Option<H160>, contract_info: ContractInfo<T> }:

  • EOADelegatedEOA is permanent; clearing only sets delegate_target = None.
  • Delegated EOAs get their own child trie keyed by the EOA's address; re-delegating preserves it.
  • Code refcounts are incremented on set, decremented on clear.
  • Clearing refunds the storage_base_deposit (code-lockup portion) but keeps the child trie and per-item accounting.

Execution.

  • Callee is a delegated EOA → code loaded from the target, storage stays the EOA's.
  • Constructors skip delegation lookup.
  • No chain following: delegation is resolved at most once (A→B→C calling A runs B's code, not C's).

Benchmarks. process_new_account_authorization(n) (worst case) and process_existing_account_authorization(n) (best case, for weight refunds).

RPC. eth-rpc can submit and dry-run EIP-7702 txs; eth_getCode returns the 0xef0100 || address prefix for delegated EOAs.

Tests

  • Validation: invalid chain_id / nonce skipped, chain_id 0 wildcard, contract accounts rejected, same-authority replay resolves to first valid entry.
  • Lifecycle: set / update / clear, delegation resolution during calls, cleared delegations stop executing.
  • Storage: re-delegation preserves storage across targets.
  • Deposits: charges/refunds, re-delegation adjustments, refcount tracking, EOA→EOA charges nothing, multiple authorities each get their own deposit.
  • Edge cases: chains not followed, SELFDESTRUCT preserves delegation, delegation to a nonexistent address is a no-op.
  • RPC: end-to-end delegate → call → clear flow.

@0xRVE 0xRVE self-assigned this May 29, 2026
@0xRVE 0xRVE added T7-smart_contracts This PR/Issue is related to smart contracts. A5-run-CI Run CI on draft PR labels May 29, 2026
@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented May 29, 2026

/cmd prdoc --audience runtime_dev --bump major

@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented May 29, 2026

/cmd bench --runtime asset-hub-westend --pallet pallet_revive

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime asset-hub-westend --pallet pallet_revive" has started 🚀 See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime asset-hub-westend --pallet pallet_revive" has failed ❌! See logs here

@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented May 29, 2026

/cmd bench --runtime asset-hub-westend --pallet pallet_revive

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime asset-hub-westend --pallet pallet_revive" has started 🚀 See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime asset-hub-westend --pallet pallet_revive" has finished ✅ See logs here

Details

Subweight results:
File Extrinsic Old New Change [%]
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs own_code_hash 4.93us 6.79us +37.76
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs instr 817.97us 1.07ms +30.27
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_call_data_load 454.00ns 558.00ns +22.91
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_now 444.00ns 543.00ns +22.30
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_block_number 457.00ns 555.00ns +21.44
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_call_data_size 428.00ns 508.00ns +18.69
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_value_transferred 476.00ns 553.00ns +16.18
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_return_data_size 448.00ns 520.00ns +16.07
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_gas_limit 464.00ns 526.00ns +13.36
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_caller 554.00ns 607.00ns +9.57
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_address 539.00ns 589.00ns +9.28
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs caller_is_root 1.95us 2.13us +9.16
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs caller_is_origin 1.99us 2.15us +8.26
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs extcodecopy 41.94us 45.39us +8.21
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_base_fee 1.45us 1.57us +8.12
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs bn128_add 18.20us 19.56us +7.43
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_code_hash 30.98us 33.14us +6.98
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_gas_price 1.43us 1.52us +6.80
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs minimum_balance 2.28us 2.43us +6.66
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_origin 575.00ns 612.00ns +6.43
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs weight_left 2.07us 2.19us +6.05
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_balance 5.45us 5.77us +5.72
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs get_transient_storage_full 2.16us 2.04us -5.87
substrate/frame/revive/src/weights.rs process_new_account_authorization 27.03ms Added
substrate/frame/revive/src/weights.rs process_existing_account_authorization 13.52ms Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs process_new_account_authorization 176.30ms Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs process_existing_account_authorization 171.66ms Added
Command output:

✅ Successful benchmarks of runtimes/pallets:
-- asset-hub-westend: ['pallet_revive']

@paritytech-workflow-stopper
Copy link
Copy Markdown

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/26634359844
Failed job name: test-linux-stable

@0xRVE 0xRVE marked this pull request as ready for review June 4, 2026 03:59
@0xRVE 0xRVE requested a review from a team as a code owner June 4, 2026 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A5-run-CI Run CI on draft PR T7-smart_contracts This PR/Issue is related to smart contracts.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants